package be.dch.gui.panels;

import java.awt.ComponentOrientation;

import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;

public class OptionPanel extends AbstractPanel {

    /** * */
    private static final long serialVersionUID = -5632682114339643726L;

    private static OptionPanel instance = new OptionPanel();
    private final transient JTabbedPane extraPane;

    protected OptionPanel() {
	super();
	this.extraPane = new JTabbedPane(SwingConstants.TOP);
	this.extraPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
	this.addAbstractPanel(SplitterPanel.getInstance());
	this.addAbstractPanel(Srtm2OsmOptionPanel.getInstance());
	this.addAbstractPanel(MkgmapPanel.getInstance());
	this.addAbstractPanel(LocationPanel.getInstance());
	this.add(this.extraPane);
    }

    public static OptionPanel getInstance() {
	return OptionPanel.instance;
    }

    @Override
    public String getPanelTitle() {
	return "Options";
    }

    @Override
    public Icon getPanelIcon() {
	return this.createImageIcon("/images/file-options-icon.png", "Options");
    }

    private void addAbstractPanel(final AbstractPanel panel) {
	this.extraPane.addTab(panel.getPanelTitle(), panel.getPanelIcon(), panel);
    }

    public void selectTab(final JComponent comp) {
	for (int i = 0; i < this.extraPane.getTabCount(); i++) {
	    this.extraPane.setSelectedComponent(comp);
	}
    }

}
